home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Stolen Data 2
/
Stolen Data 2.adf
/
Source
/
Cube.s
next >
Wrap
Text File
|
1989-11-02
|
5KB
|
339 lines
Incdir Df1:
Include Source/CustomRegisters
Section Cube,Code_c
Ciaapra = $BFE001
Openlibrary = -30-522
Disable = -120
Enable = -126
Startlist = 38
Execbase = 4
Move.l Execbase,a6
Jsr Disable(a6)
;-------- Switch Copper DMA ----------
Move.l #Clstart,Cop1lc
Clr Copjmp1
Move.w #$8780,Dmacon
Move.w #$0020,Dmacon
Lea Spr0data,a0
Moveq #7,d0
Clop
Clr.l (a0)
Addq.l #8,a0
Dbf d0,Clop
;------ Wait for Vertical position 1 --------
Wait: Move.l $dff004,d2
And.l #$0001ff00,d2
Cmp.l #$00000100,d2
Bne.s Wait
Addq #2,Zrot
And #$1fe,Zrot
Addq #4,Yrot
And #$1fe,Yrot
Subq #2,Xrot
And #$1fe,Xrot
Bsr TD_rout
Btst #6,Ciaapra
Bne Wait
;------ Restore old Copper list -----------
Move.l Execbase,a6
Move.l #Grname,a1
Clr.l d0
Jsr Openlibrary(a6)
Move.l d0,a4
Move.l Startlist(a4),Cop1lc
Clr.w Copjmp1
Move.w #$83E0,Dmacon
Jsr Enable(a6)
Clr.l d0
Rts
;--------- 3D graphics ------------
TD_rout
Move.l Current(pc),d0
Move d0,Screen+2
Swap d0
Move d0,Screen+6
Eor.l #$3000,Current
Move.l Current(pc),a0
Move.l #$1f00000,Bltcon0
Move.l a0,Bltdpth
Clr Bltadat
Clr Bltdmod
Move #256*64+20,Bltsize
Move #No_points-1,d7
Lea Points(pc),a4
Lea Sintable+$40(pc),a1
Lea Rotated_coords(pc),a2
Lea Perspective(pc),a3
TD_loop
Move (a4)+,d0
Move d0,d2
Move (a4)+,d1
Move d1,d3
Move Zrot(pc),d6
Move $40(a1,d6),d4
Move -$40(a1,d6),d5
Muls d4,d0
Muls d5,d1
Sub.l d1,d0
Add.l d0,d0
Swap d0 ;d0 holds intermediate x coord
Muls d5,d2
Muls d4,d3
Add.l d3,d2
Add.l d2,d2
Swap d2 ;d2 holds intermediate y coord
Move d2,d4
Move (a4)+,d1 ;z coord
Move d1,d3
Move Xrot(pc),d6
Move $40(a1,d6),d5
Move -$40(a1,d6),d6
Muls d5,d2
Muls d6,d1
Sub.l d1,d2
Add.l d2,d2
Swap d2 ;d2 holds the final y coord
Muls d5,d3
Muls d6,d4
Add.l d4,d3
Add.l d3,d3
Swap d3 ;d3 holds intermediate z coord
Move d0,d1
Move d3,d4
Move Yrot(pc),d6
Move $40(a1,d6),d5
Move -$40(a1,d6),d6
Muls d5,d3
Muls d6,d0
Sub.l d0,d3
Add.l d3,d3
Swap d3 ;d3 holds the final z coord
Muls d6,d4
Muls d5,d1
Add.l d4,d1
Add.l d1,d1
Swap d1 ;d1 holds the final x coord
Add Depth(pc),d3
Add d3,d3
Move (a3,d3),d5
Muls d5,d1
Muls d5,d2
Add.l d1,d1
Swap d1
Add #160,d1
Add.l d2,d2
Swap d2
Add #128,d2
Move d1,(a2)+
Move d2,(a2)+
Dbf d7,TD_loop
Move #No_connects-1,d7
Lea $dff000,a5
Lea Connect(pc),a3
Lea Rotated_coords(pc),a4
Moveq #40,d0
Lea Mul40(pc),a1
Lea Bits(pc),a2
Lea Faces(pc),a6
B_wait2
Btst #14,Dmaconr
Bne.s B_wait2
Move #$ffff,Bltafwm
Move d0,$60(a5) ;Bltcmod
Move d0,$66(a5) ;Bltdmod
Move #$ffff,$72(a5) ;Bltbdat
Draw_loop
Move (a3)+,d6
Move (a4,d6),d0
Move 2(a4,d6),d1
Move (a3)+,d6
Move (a4,d6),d2
Move 2(a4,d6),d3
Cmp d0,d2
Bne.s Draw
Cmp d1,d3
Beq.s Nodraw
Draw
Bsr Line
Nodraw
Dbf d7,Draw_loop
Bwit
Btst #14,Dmaconr
Bne.s Bwit
Rts
;----------- Line Draw ------------
Line
Moveq #0,d4
Move d1,d4
Add d4,d4
Move (a1,d4),d4
Moveq #-$10,d5
And d0,d5
Lsr #3,d5
Add d5,d4
Add.l a0,d4
Moveq #0,d5
Sub d1,d3
Roxl.b d5
Tst d3
Bge.s Y2gy1
Neg d3
Y2gy1
Sub d0,d2
Roxl.b d5
Tst d2
Bge.s X2gx1
Neg d2
X2gx1
Move d3,d1
Sub d2,d1
Bge.s Dygdx
Exg d2,d3
Dygdx
Roxl.b d5
Move.b Octant_table(pc,d5),d5
Add d2,d2
Wblit
Btst #14,Dmaconr
Bne.s Wblit
Move d2,$62(a5) ;Bltbmod
Sub d3,d2
Bge.s Signn1
Or.b #$40,d5
Signn1
Move d2,$52(a5) ;Bltaptl
Sub d3,d2
Move d2,$64(a5) ;Bltamod
Move #$8000,$74(a5) ;Bltadat
Add d0,d0
Move (a2,d0),$40(a5) ;Bltcon0
Move d5,$42(a5) ;Bltcon1
Move.l d4,$48(a5) ;Bltcpth
Move.l d4,$54(a5) ;Bltdpth
Lsl #6,d3
Addq #2,d3
Move d3,$58(a5) ;Bltsize
Rts
;---------- Constants -------------
Octant_table
Dc.b 1,17,9,21,5,25,13,29
Grname: Dc.b "graphics.library",0
Even
;----------- Variables ------------
Xrot Dc.w $100
Yrot Dc.w 0
Zrot Dc.w 0
Current Dc.l $70000
Depth Dc.w 180
Depthpt Dc.w 0
;---------- Copperlists -----------
Clstart:
Wait 0,20
Mov $1a81,Diwstrt
Mov $39c1,Diwstop
Mov $0038,Ddfstrt
Mov $00d0,Diwstop
Screen
Mov 0,Bpl1ptl
Mov 7,Bpl1pth
Mov $1200,Bplcon0
Mov 0,Bpl1mod
Mov 0,Color00
Mov $fff,Color01
Wait 224,255
Wait $fe,$ff
;--------- Binaries -------------
No_points = 8
No_connects = 12
No_faces = 6
Points
Dc.w 100,100,100
Dc.w -100,100,100
Dc.w -100,-100,100
Dc.w 100,-100,100
Dc.w 100,100,-100
Dc.w -100,100,-100
Dc.w -100,-100,-100
Dc.w 100,-100,-100
Connect
Dc.w 0,4
Dc.w 4,8
Dc.w 8,12
Dc.w 12,0
Dc.w 16,20
Dc.w 20,24
Dc.w 24,28
Dc.w 28,16
Dc.w 0,16
Dc.w 4,20
Dc.w 8,24
Dc.w 12,28
Rotated_coords
Dcb.w No_points*2,0
Sintable
Incbin Binary/Sin
Incbin Binary/Sin
Perspective
Incbin Binary/Perspective
Mul40
A set 0
Rept 320
Dc.w A*40
A set A+1
Endr
A set 0
Bits
Rept 320
Dc.w ((A&$f)*$1000)+$bca
A set A+1
Endr
Size
A set 0
Rept 320
Dc.w (A*64)+2
A set A+1
Endr